package com.johnlee.sentinel_quick_start.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController_05 {

    // 定义限流资源和限流降级回调函数
    @SentinelResource(value = "Sentinel_Ann", blockHandler = "exceptionHandler")
    @GetMapping("helloAnn")
    public String helloAnn(){
        return "Hello Sentinel Annotation Resource";
    }

    public String exceptionHandler(BlockException e){
        e.printStackTrace();
        return "busy";
    }
}
